package controller;

import controller.dialog.DialogExit;
import javafx.event.EventHandler;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;

/**
 * Controller de eventos do teclado para o jogo inteiro
 * @author Adriano
 */
public class KeyBordJogoEventos implements EventHandler<KeyEvent> {
    private KeyEvent oldEvent;
    
    @Override
    public void handle(KeyEvent event) {
        //Tecla ESC
        if (event.getCode().equals(KeyCode.ESCAPE)) {
            try {
                DialogExit.getIntancia().show();
            } catch (Exception e) {}
        }
        //Evento Alt+F4
        if (event.getCode().equals(KeyCode.F4) && oldEvent.getCode().equals(KeyCode.ALT)) {
            System.exit(0);
        }
        oldEvent = event;
        event.consume();
    }
}
